import 'package:woniutaofang/utils/themcolor.dart';
import 'package:woniutaofang/utils/theme_utils.dart';
import 'package:flutter/material.dart';

class MyCard extends StatelessWidget {
  const MyCard({Key key, @required this.child, this.color, this.shadowColor})
      : super(key: key);

  final Widget child;
  final Color color;
  final Color shadowColor;

  @override
  Widget build(BuildContext context) {
    Color _backgroundColor;
    Color _shadowColor;
    final bool isDark = ThemeUtils.isDark(context);
    if (color == null) {
      _backgroundColor = isDark ? Colours.dark_bg_gray_ : Colors.white;
    } else {
      _backgroundColor = color;
    }

    if (shadowColor == null) {
      _shadowColor = isDark ? Colors.transparent : Colors.grey[100];
    } else {
      _shadowColor = isDark ? Colors.transparent : shadowColor;
    }

    return DecoratedBox(
      decoration: BoxDecoration(
        color: _backgroundColor,
        boxShadow: [
          BoxShadow(
              color: _shadowColor,
              offset: const Offset(0.0, 10.0),
              blurRadius: 8.0,
              spreadRadius: 1.0),
        ],
      ),
      child: child,
    );
  }
}
